% construct the wage distribution (Pareto Log Normal)
function res = alphadist(x,pr)

mu        = x(1);  % normal mean
sig       = x(2);  % normal sd
w         = exp(linspace(log(pr.wmin),log(pr.wmax),pr.na)'); % grid for exp(alpha), linearly spaced in log
pdf       = pr.pareto./2.*exp(pr.pareto./2.*(2.*mu+pr.pareto.*sig^2-2.*log(w))).*erfc((mu+pr.pareto*sig^2-log(w))./(2^(1/2)*sig)); % EMG density
pai       = pdf./sum(pdf); % probablity measure

res       = [ sum(w.*pai)-1 ; sum((log(w)-sum(log(w).*pai)).^2.*pai)-pr.va ];

disp([x;res'])
save w w
save pai pai
save pdf pdf